package com.seed.uaa.login.impl;

import com.seed.core.pojo.Account;
import com.seed.core.pojo.Admin;
import com.seed.core.pojo.LoginDTO;
import com.seed.uaa.login.Login;

public class LoginImpl implements Login {
    private Login login;
    private final LoginDTO dto;
    private final Account account;

    public LoginImpl(LoginDTO dto, Admin admin) {
        this.dto = dto;
        this.account = new Account(dto.getUsername());
        this.login = switch (account.getType()) {
            case admin -> new AdminLogin(admin);
            case userCode -> new UserCodeLogin();
            case userUsername -> new UserUsernameLogin();
            case tenantUsername -> new TenantUsernameLogin();
            case tenantUserCode -> new TenantUserCodeLogin();
            case tenantUserUsername -> new TenantUserUsernameLogin();
        };
    }

    @Override
    public void login(Account account, LoginDTO dto) {
        login.login(account,dto);
    }
}
